package com.yuanqi.Controller;

import com.yuanqi.Common.Pojo.entity.Comment;
import com.yuanqi.Return.Result;
import com.yuanqi.Service.CommentService;
import org.springframework.web.bind.annotation.*;
import com.yuanqi.Common.Pojo.Vo.commentVo;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/v1/comment")
@CrossOrigin
public class CommentController {
    @Resource
    CommentService commentService;
    @GetMapping
    public Result getCommentByPostId(Integer postId,Integer current,Integer size)
    {
       List<commentVo> list = commentService.getCommentByPostId(postId,current,size);
       return  Result.success(list);
    }
    @PostMapping("/AddComment")
    public Result AddComment(@RequestBody commentVo commentVo)
    {
        Comment comment =  commentService.AddComment(commentVo);
        return Result.success(comment);
    }
}
